Ext.define('Egitim.view.KatilimciList', {
    extend: 'Ext.grid.Panel',
    alias: 'widget.katilimcilist',
    store: 'Katilimci',
	projeId: '',
	
	initComponent: function (){		
		var me = this;
		
		me.selModel = {
		    selType: 'checkboxmodel'
		    , mode: 'MULTI'
		};
		
		me.store = Ext.create('Egitim.store.Katilimci', {
			projeId: me.projeId
		});
		
		me.dockedItems = [{
	        dock: 'top',
	        xtype: 'toolbar',
	        items: [{
	        	xtype: 'button',
	        	iconCls: 'grup',
	        	action: 'grupla',
	        	tooltip: 'Seçilenleri gruplandır',
	        	handler: function () {
					this.up('panel').down('#grupadi').setVisible(true);
				}
	        },{
	        	xtype: 'textfield',
	        	itemId: 'grupadi',
	        	hidden: true,
	        	emptyText: 'Grup ismi giriniz'
	        },'-',{
	        	xtype: 'button',
	        	iconCls: 'aktif',
	        	tooltip: 'Seçilenleri aktif yap',
	        	action: 'aktif'
	        },{
	        	xtype: 'button',
	        	iconCls: 'pasif',
	        	tooltip: 'Seçilenleri pasif yap',
	        	action: 'pasif'
	        },{
	            glyph: 61,
	            xtype: 'button',
				handler: function () {
					var form = this.up('panel').down('#searchform');
					form.setVisible(form.isHidden());
				}
	        }, {
	            xtype: 'form',
				itemId: 'searchform',
				layout: 'vbox',
				border: false,
				hidden: true,
				defaultType: 'textfield',
				items: [{
					fieldLabel: 'Ad',
					labelWidth: 40,
					name: 'ad',
					tip: 's'
				},{
					fieldLabel: 'Soyad',
					labelWidth: 40,
					name: 'soyad',
					tip: 's'
				}]
	        }]
	    },{
	        xtype: 'pagingtoolbar',
	        store: me.store,
	        dock: 'bottom',
	        displayInfo: true
	    }];
		
        me.callParent();
		me.addEvents('silkatilimci', 'guncellekatilimci');
	},
	
	selectable: false, //seçim içinse true
	features: [{ftype:'grouping'}],
	columns: [
        { text: 'Ad',  dataIndex: 'ad', flex: 1},
        { text: 'Soyad', dataIndex: 'soyad', flex: 1 },
        { text: 'E-Posta', dataIndex: 'eposta' },
        { text: 'Onay', dataIndex: 'onay', renderer: function (v){return v?'Evet':'Hayır';} },
        { text: 'Oluşturuldu', dataIndex: 'created'},
		{
            xtype:'actioncolumn',
            width:50,
            items: [{
                icon: 'egitimapp/resources/icons/edit.png',  // Use a URL in the icon config
                tooltip: LBL_GUNCELLE,
                handler: function(grid, rowIndex, colIndex) {
                    var rec = grid.getStore().getAt(rowIndex);
					grid.up('katilimcilist').fireEvent('guncellekatilimci', grid, rec);
                },
                getClass: function (v, md, record){
                	return this.up('katilimcilist').selectable ? 'hidden' : '';
                }
            },{
                icon: 'egitimapp/resources/icons/delete.gif',
                tooltip: 'Sil',
                handler: function(grid, rowIndex, colIndex) {
                    var rec = grid.getStore().getAt(rowIndex);
					grid.up('katilimcilist').fireEvent('silkatilimci', grid, rec);
                },
                getClass: function (v, md, record){
                	return this.up('katilimcilist').selectable ? 'hidden' : '';
                }
            }]
        }		
    ]
    
});